package com.obv;

import java.util.ArrayList;
import java.util.List;

public abstract class Subjects {
	protected float price,price1;
	protected String code;
	protected List<observer> observerlist;
	public void add(observer obser){
		observerlist.add(obser);
	}
	
	public void rermove(observer obser){
		observerlist.remove(obser);
	}
	
	public Subjects(String code){
		this.code=code;
		price=price1=0;
		observerlist=new ArrayList<observer>();
	}
	
	public float getprice(){
		return price;
	}
	
	public void setprice(float price){
		this.price=price;
		notifyholder();
	}

	public abstract void notifyholder();
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		final int prime=31;
		int result=1;
		result=prime*result+(code==null? 0:code.hashCode());
		return result;
	}
	
	public float getPrice1() {
		return price1;
	}

	public void setPrice1(float price1) {
		this.price1 = price1;
	}

	@Override
	public boolean equals(Object obj) {
		// TODO Auto-generated method stub
		if(this==obj)
			return true;
		if(obj==null)
			return false;
		if(getClass()!=obj.getClass())
			return false;
		Subjects other=(Subjects) obj;
		if(code==null){
			if(other.code!=null)
				return false;
		}else if(!code.equals(other.code))
			return false;
		return super.equals(obj);
	}

}
